package com.x52im.rainbowchat.http.util;

import com.x52im.rainbowchat.http.logic.dto.RedEnvelopeDTO;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;

import java.io.IOException;

public class RedissonTools {
    public static Redisson redisson = null;

    static {
        Config config = new Config();
        String url = "redis://127.0.0.1:6379";
        config.useSingleServer().setAddress(url).setConnectionPoolSize(250).setConnectionMinimumIdleSize(10).setDatabase(RedEnvelopeDTO.REDIS_DB_INDEX).setKeepAlive(true);
        redisson = (Redisson) Redisson.create(config);
    }

//    public static Redisson getRedisson(int index) {
//        Config config = new Config();
//        String url = "redis://" + BaseConf.getInstance().getREDIS_HOST() + ":" + BaseConf.getInstance().getREDIS_PORT();
//        config.useSingleServer().setAddress(url).setPassword(BaseConf.getInstance().getREDIS_PASSWORD()).setDatabase(index).setKeepAlive(true);
//        Redisson redisson = (Redisson) Redisson.create(config);
//        return redisson;
//    }

//    public static RedissonClient getRedisson(int index) throws IOException {
//        Config config = new Config();
//        String url = "redis://127.0.0.1:6379";
//        config.useSingleServer().setAddress(url).setConnectionPoolSize(250).setConnectionMinimumIdleSize(10).setDatabase(index).setKeepAlive(true);
//        RedissonClient redisson = Redisson.create(config);
//        return redisson;
//    }
}
